package com.hospital.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hospital.util.DbUtil;

@WebServlet("/manage/DictServlet")
public class DictServlet extends HttpServlet {
	//检查项目信息Servlet
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String method = request.getParameter("method");
		if ("add".equals(method)) {
			String type = request.getParameter("type").trim();
			String item = request.getParameter("item").trim();
			String value = request.getParameter("value").trim();
			String sql = "insert into t_dict(type, item, value) values('" + type + "', '" + item + "','" + value + "')";
			DbUtil.add_modify(sql);
		} else if ("del".equals(method)) {
			String[] id = request.getParameterValues("selectFlag");
			DbUtil.del("t_dict", id);
		} else if ("modify".equals(method)) {
			int id = Integer.parseInt(request.getParameter("id"));
			String type = request.getParameter("type").trim();
			String item = request.getParameter("item").trim();
			String value = request.getParameter("value").trim();
			String sql = "update t_dict set type = '" + type + "', item = '" + item + "', value = '" + value + "' where id = " + id;
			DbUtil.add_modify(sql);
		}
		request.getRequestDispatcher("/manage/dict_manage.jsp").forward(request, response);
	}
}
